﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IPagedList<sp_GetGlobalSearchResult>>" %>
<table width="100%" cellpadding="0" cellspacing="0">
    <tr>
        <td>
            
                <%
                    List<sp_GetGlobalSearchResult> listNewPartner = (List<sp_GetGlobalSearchResult>)ViewData.Model;
                    if (((List<sp_GetGlobalSearchResult>)ViewData.Model).Count == 0)
                        Response.Write("Không có đối tác nào");
                    else
                    {
                        int y = 0;
                        for (int i = 0; i < listNewPartner.Count; i += 3)
                        {%>
                <ul>
                    <%for (int z = 0; z < 3; z++)
                      {
                          if (y < listNewPartner.Count)
                          {
                              sp_GetGlobalSearchResult obj = listNewPartner[y];%>
                    <li>
                        <div class="cimage">
                            <img src="<%=Constants.PHOTO_PATH_ROOT_PARTNER + obj.Logo%>" width="208" height="132" /></div>
                        <a class="textlink2 text" href="<%=FRouter._("cuahang",obj.ID.ToString(),obj.PartnerName) %>">
                            <strong>
                                <%=Html.Encode(obj.PartnerName)%></strong></a>
                        <div class="style">
                            <%=Html.Encode(CommonFunc.GetMainPartnerAddress(obj.ID))%>
                            <br />
                            Ðiện thoại:
                            <%=obj.RepresentativePhone%>
                            <br />
                            Giảm giá:
                            <%=HttpUtility.HtmlEncode(obj.DiscountInfo)%>
                        </div>
                    </li>
                    <% y++;
              }
          } %>
                </ul>
                <%}
                %>
                <%}
                %>
           
            
        </td>
       
    </tr>
    <tr>
        <td>
            <div class="pagination">
                <%= Ajax.Pager(new AjaxOptions { UpdateTargetId = "searchpartner", OnBegin = "beginPaging", OnSuccess = "successPaging", OnFailure = "failurePaging" },
                             ViewData.Model.PageSize, ViewData.Model.PageNumber, ViewData.Model.TotalItemCount, new { controller = "Home", action = "GlobalSearch" })%>
            </div>
        </td>
    </tr>
</table>
<script type="text/javascript">

    function beginPaging(args) {
        // Animate
        $('#searchpartner').fadeOut('normal');
    }

    function successPaging() {
        // Animate
        $('#searchpartner').fadeIn('normal');
    }

    function failurePaging() {
        alert("Could not retrieve products.");
    }

    </script>